package com.zhz.lib.cms.exception;
import java.io.PrintStream;
import java.io.PrintWriter;

import org.apache.log4j.Logger;

/**
 * 抛出libcms异常
 * 
 * @author zhangkai
 * @version 1.0 2009-12-19
 * @copyright zhznet.com
 */
public class LibcmsException extends Exception {

	private static final long serialVersionUID = -1721164101083849313L;

	private Throwable nestedThrowable = null;
	protected Logger log = Logger.getLogger(LibcmsException.class);

	 
	public LibcmsException(String msg) {
		super(msg);
		log.error(msg);
	}

	 
	public LibcmsException(Throwable nestedThrowable) {
		this.nestedThrowable = nestedThrowable;
		log.error(nestedThrowable);
	}

 
	public LibcmsException(String msg, Throwable nestedThrowable) {
		super(msg);
		this.nestedThrowable = nestedThrowable;
		log.error(msg, nestedThrowable);
	}

	public void printStackTrace() {
		super.printStackTrace();
		if (nestedThrowable != null) {
			nestedThrowable.printStackTrace();
		}
	}

 
	public void printStackTrace(PrintStream ps) {
		super.printStackTrace(ps);
		if (nestedThrowable != null) {
			nestedThrowable.printStackTrace(ps);
		}
	}

	 
	public void printStackTrace(PrintWriter pw) {
		super.printStackTrace(pw);
		if (nestedThrowable != null) {
			nestedThrowable.printStackTrace(pw);
		}
	}
}
